<div class="SipeiMain_r fr">
      <h2 class="clearfix fonts_18 height45 fontc_444"><?php echo $this->title;?></h2>
	   <?php
	   $form = $this->beginWidget('CActiveForm', array(
	   'action' => Yii::app()->createUrl($this->route),
	   'method' => 'POST',
	   'id' => 'searchForm'));
		?>
      <ul class="clearfix back_bgf border_3 border_c pr30 pl20 pt20 pb20 height32 fontc_666">
      <input type="hidden" name="info[id]" value="<?php echo isset($serch['reportrule']['id'])?$serch['reportrule']['id']:''; ?>">
        <li class="fl pt10 pr20 pb10 pl8">
            <span class="pr3">城市代码：</span>
            <input type="text" name="info[code]" id="code" value="<?php echo isset($serch['reportrule']['code'])?$serch['reportrule']['code']:''; ?>" class="pt6 pr5 pb6 pl5 border_3 border_c fontc_666 w100" />
            <div class="formValidator_tip" style="margin-left:63px;width:115px;">
                <p id="codeTip" ></p>
            </div>
        </li>
        <li class="fl pt10 pr30 pb10 pl3">
            <span class="pr3">上报简称：</span><input type="text" name="info[name]" id="name" value="<?php echo isset($serch['reportrule']['name'])?$serch['reportrule']['name']:''; ?>" class="pt6 pr5 pb6 pl5 border_3 border_c fontc_666 w100" />
            <div class="formValidator_tip" style="margin-left:63px;width:115px;">
                <p id="nameTip" ></p>
            </div>
        </li>
        <li class="fl pt10 pr30 pb10">
            <span class="pr3">城市名称：</span><input type="text" name="info[cityname]" id="cityname" value="<?php echo isset($serch['reportrule']['cityname'])?$serch['reportrule']['cityname']:''; ?>" class="pt6 pr5 pb6 pl5 border_3 border_c fontc_666 w100" />
            <div class="formValidator_tip" style="margin-left:63px;width:115px;">
                <p id="citynameTip" ></p>
            </div>
        </li>
        <li class="fr pt10 pb10">
            <input type="submit" value="编辑" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
        </li>
        <li class="fl pt10 pr20 pb10 pl8">
            <span style="width:64px;" class="fl">备注：</span>
            <textarea name="info[remark]" class="col3 pt6 pr10 pb6 pl10 border_c border_3 fontc_666"><?php echo isset($serch['reportrule']['remark'])?$serch['reportrule']['remark']:''; ?></textarea>
        </li>
      </ul>
	 <?php
	 $this->endWidget();
	?>
    <div class="clearfix back_bgf border_c mt15 pt20 pb20">
        <div class="clearfix pb20 pl30">
            <input type="button" value="新增" onclick="add(<?php echo isset($serch['reportrule']['id'])?$serch['reportrule']['id']:''; ?>);" style="margin-right:30px;"  class="fr b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 mr10 cursor" />
            <input type="button" value="删除" onclick="delete_all()" class="fl b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
        </div>
        <table class="height40" width="100%">
            <thead class="back_bgf5 fontc_666">
                <tr>
                    <th width="35" align="right" class="m_hr_t m_hr_b pr10"><input type="checkbox" class="checkboxs"></th>
                    <th width="65" align="center" class="m_hr_t m_hr_b">序号</th>
                    <th width="100" align="center" class="m_hr_t m_hr_b">字段名称</th>
                    <th width="100" align="center" class="m_hr_t m_hr_b">数据类型</th>
                    <th width="100" align="center" class="m_hr_t m_hr_b">字段长度</th>
                    <th width="80" align="center" class="m_hr_t m_hr_b">小数位</th>
                    <th width="100" align="center" class="m_hr_t m_hr_b">对应栏位</th>
                    <th width="80" align="center" class="m_hr_t m_hr_b">固定值</th>
                    <th width="40" align="center" class="m_hr_t m_hr_b">生效</th>
                    <th width="90" align="center" class="m_hr_t m_hr_b">操作</th>
                </tr>
            </thead>
            <tbody class="fontc_444">
                <?php if (!empty($data)): ?>
                    <?php foreach ($data as $value): ?>
                        <tr>
                            <td align="right" class="m_hr_b pr10"><input type="checkbox" name="deleteAll[]" value="<?php echo $value['id'];?>" class="checkbox"></td>
                            <td align="center" class="m_hr_b"><?php echo $value['number']; ?></td>
                            <td align="center" class="m_hr_b"><?php echo $value['name']; ?></td>
                            <td align="center" class="m_hr_b"><?php $tabletype = Import::_gettabletype(); echo $tabletype[$value['type']];?></td>
                            <td align="center" class="m_hr_b"><?php echo $value['length']; ?></td>
                            <td align="center" class="m_hr_b"><?php echo $value['float']; ?></td>
                            <td align="center" class="m_hr_b">
                            <?php 
                            $tableinfo = Import::_gettableinfo('student');
                            foreach ($tableinfo as $k=>$v):
                            if ($v['COLUMN_NAME']==$value['row']):echo $v['COMMENTS'];
                            endif;
                            endforeach;
                            ?>
                            </td>
                            <td align="center" class="m_hr_b"><?php echo $value['value']; ?></td>
                            <td align="center" class="m_hr_b">
                                <input disabled='' type="checkbox" <?php echo $value['status'] == 1 ? 'checked=checked' : ''; ?> />
                            </td>
                            <td align="center" class="m_hr_b">
                                <img src="/themes/default/images/Sipei/edit.png" class="mr10 cursor" onclick="update(<?php echo $value['id']; ?>)" title="编辑"  />
                                <img src="/themes/default/images/Sipei/delate.png" class="cursor" onclick="set_ok(<?php echo $value['id']; ?>,<?php echo $value['status'];?>)" title="删除" />
                            </td>
                        </tr>
                    <?php endforeach; ?>
                <?php else: ?>
	                    <tr>
	                        <td colspan="10"><h1 align="center">暂无数据</h1></td>
	                    </tr>
                <?php endif; ?>
            </tbody>
        </table>
        <?php 
        if($pages):
        $this->renderPartial('//partial/partial_pager', array('pages' => $pages, "url" => $pageUrl));
        endif; ?>
    </div>
</div>
<script>
function set_ok(id,is_del) {

	$.dialog.confirm('确定删除吗', function() {
		//location.href = "<?php echo $this->createUrl("delete") ?>/id/" + id;
		$.get('/report_rule/default/delete_all', {id: id}, function(data) {
			location.reload();
		});
	});
}
function delete_all(){
	var aa='';
	$("input[name='deleteAll[]']:checkbox:checked").each(function(){
		aa+=$(this).val()+',';
	});
	if(aa == ''){
		$.dialog.alert("请选择要删除条目");
		return false;
	}
	$.dialog.confirm('确定删除所选数据吗', function() {
		aa+=0;
		$.get('/report_rule/default/delete_all', {id: aa}, function(data) {
			location.reload();
		});
	});
}
function add(id) {
	api = $.dialog({
		id: 'testID2',
		lock: true,
		padding: 0,
		fixed: true,
		title: "新增",
		width: 480,
		height: 530,
		max: false,
		min: false
	});
	$.get('/report_rule/default/add', {id: id}, function(html) {
		api.content(html);
	});
}
function update(id) {
	api = $.dialog({
		id: 'testID2',
		lock: true,
		padding: 0,
		fixed: true,
		title: "编辑",
		width: 480,
		height: 530,
		max: false,
		min: false
	});
	$.post('/report_rule/default/update', {id: id}, function(html) {
		api.content(html);
	});
}
$(function() {
	$(".checkboxs").click(function() {
		var checkedS = $(this).attr("checked");
		if (checkedS) {
			$(".checkbox").attr("checked", true)
		} else {
			$(".checkbox").removeAttr("checked")
		}
	})

})

$.formValidator.initConfig({formID: "searchForm", theme: "126", submitOnce: false,
onError: function(msg, obj, errorlist) {
	$("#errorlist").empty();
	$.map(errorlist, function(msg) {
		$("#errorlist").append("<li>" + msg + "</li>")
	});
	alert(msg);
},
ajaxPrompt: '有数据正在异步验证，请稍等...'
});

/*城市代码*/
$("#code").formValidator({
	onShowText: "请输入城市代码",
	onShow: "",
	onFocus: "",
	onCorrect: "输入正确",
	leftTrim:true,
	rightTrim:true
}).inputValidator({
	min: 1,
	onError: "城市代码不能为空"
});

/*上报简称验证*/
$("#name").formValidator({
	onShowText: "请输入上报简称",
	onShow: "",
	onFocus: "",
	onCorrect: "输入正确",
	leftTrim:true,
	rightTrim:true
}).inputValidator({
	min: 1,
	onError: "上报简称不能为空"
});

/*城市名称验证*/
$("#cityname").formValidator({
	onShowText: "请输入城市名称",
	onShow: "",
	onFocus: "",
	onCorrect: "输入正确",
	leftTrim:true,
	rightTrim:true
}).inputValidator({
	min: 1,
	onError: "城市名称不能为空"
});



</script>